#include <my_head.h>

int main(int argc, const char *argv[]){
    if(3 != argc){
        printf("Usage : %s src_file dest_file\n", argv[0]);
        return -1;
    }
    // 打开文件
    int fd_r = open(argv[1], O_RDONLY);
    if(-1 == fd_r)
        ERR_LOG("open error");
    int fd_w = 0;
    if(-1 == (fd_w = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0664)))
        ERR_LOG("open error");
    // 拷贝
    char buff[10];
    int nbytes = 0;
    while(0 < (nbytes = read(fd_r, buff, sizeof(buff)))){
        write(fd_w, buff, nbytes);
    }
    // 关闭文件
    close(fd_r);
    close(fd_w);
    return 0;
}